#ifndef _DEMO_H
#define _DEMO_H

#include <gtk/gtk.h>
#include "Enesim.h"

#if HAVE_EMAGE
#include "Emage.h"
#endif

#if HAVE_ETEX
#include "Etex.h"
#endif

typedef struct _Application Application;

void application_render(Application *app);
void shape_setup(Application *app, GtkWidget *box);
Enesim_Renderer * enesim_renderer_raddist_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_renderer_stripes_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_renderer_checker_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_renderer_grid_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_renderer_perlin_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_renderer_dispmap_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_renderer_circle_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_renderer_ellipse_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_renderer_rectangle_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * fancy_button01_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * fancy_button02_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * fancy_progress01_setup(Application *app, GtkWidget *frame);
Enesim_Renderer * enesim_text_setup(Application *app, GtkWidget *frame);

void fancy_button01_radius_set(Enesim_Renderer *r, float radius);
float fancy_button01_radius_get(Enesim_Renderer *r);
Enesim_Renderer * fancy_button01_new(void);

static inline enesim_color_from_gdk(Enesim_Color *color, GdkColor *gdkcolor, guint16 alpha)
{
	uint8_t a, r, g, b;
	uint16_t apre;

	a = alpha >> 8;
	r = gdkcolor->red >> 8;
	g = gdkcolor->green >> 8;
	b = gdkcolor->blue >> 8;

	apre = a + 1;
	if (apre != 256)
	{
		*color = a << 24 | (((r * apre) >> 8) << 16) | (((g * apre) >> 8) << 8) | ((b * apre) >> 8);
	}
	else
	{
		*color = a << 24 | r << 16 | g << 8 | b;
	}
}


#endif
